
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.CurePig;
import cn.edu.scau.cmi.hombio.domain.CureTaskCourse;
import cn.edu.scau.cmi.hombio.domain.Employee;
import cn.edu.scau.cmi.hombio.domain.Pig;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class CurePigServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CurePigService service;

	/**
	 * Instantiates a new CurePigServiceTest.
	 *
	 */
	public CurePigServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCurePigByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCurePigByPrimaryKey 
		Integer id = 0;
		CurePig response = null;
		response = service.findCurePigByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findCurePigByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing Pig entity
	* 
	 */
	@Test
	public void deleteCurePigPig() {
		// TODO: JUnit - Populate test inputs for operation: deleteCurePigPig 
		Integer curepig_id = 0;
		Integer related_pig_id = 0;
		CurePig response = null;
		response = service.deleteCurePigPig(curepig_id, related_pig_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCurePigPig
	}

	/**
	 * Operation Unit Test
	* Delete an existing CurePig entity
	* 
	 */
	@Test
	public void deleteCurePig() {
		// TODO: JUnit - Populate test inputs for operation: deleteCurePig 
		CurePig curepig = new cn.edu.scau.cmi.hombio.domain.CurePig();
		service.deleteCurePig(curepig);
	}

	/**
	 * Operation Unit Test
	* Save an existing Pig entity
	* 
	 */
	@Test
	public void saveCurePigPig() {
		// TODO: JUnit - Populate test inputs for operation: saveCurePigPig 
		Integer id_1 = 0;
		Pig related_pig = new cn.edu.scau.cmi.hombio.domain.Pig();
		CurePig response = null;
		response = service.saveCurePigPig(id_1, related_pig);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCurePigPig
	}

	/**
	 * Operation Unit Test
	* Delete an existing Employee entity
	* 
	 */
	@Test
	public void deleteCurePigEmployee() {
		// TODO: JUnit - Populate test inputs for operation: deleteCurePigEmployee 
		Integer curepig_id_1 = 0;
		Integer related_employee_id = 0;
		CurePig response = null;
		response = service.deleteCurePigEmployee(curepig_id_1, related_employee_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCurePigEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing Employee entity
	* 
	 */
	@Test
	public void saveCurePigEmployee() {
		// TODO: JUnit - Populate test inputs for operation: saveCurePigEmployee 
		Integer id_2 = 0;
		Employee related_employee = new cn.edu.scau.cmi.hombio.domain.Employee();
		CurePig response = null;
		response = service.saveCurePigEmployee(id_2, related_employee);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCurePigEmployee
	}

	/**
	 * Operation Unit Test
	* Save an existing CurePig entity
	* 
	 */
	@Test
	public void saveCurePig() {
		// TODO: JUnit - Populate test inputs for operation: saveCurePig 
		CurePig curepig_1 = new cn.edu.scau.cmi.hombio.domain.CurePig();
		service.saveCurePig(curepig_1);
	}

	/**
	 * Operation Unit Test
	* Save an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void saveCurePigCureTaskCourse() {
		// TODO: JUnit - Populate test inputs for operation: saveCurePigCureTaskCourse 
		Integer id_3 = 0;
		CureTaskCourse related_curetaskcourse = new cn.edu.scau.cmi.hombio.domain.CureTaskCourse();
		CurePig response = null;
		response = service.saveCurePigCureTaskCourse(id_3, related_curetaskcourse);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCurePigCureTaskCourse
	}

	/**
	 * Operation Unit Test
	* Return all CurePig entity
	* 
	 */
	@Test
	public void findAllCurePigs() {
		// TODO: JUnit - Populate test inputs for operation: findAllCurePigs 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CurePig> response = null;
		response = service.findAllCurePigs(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCurePigs
	}

	/**
	 * Operation Unit Test
	* Return a count of all CurePig entity
	* 
	 */
	@Test
	public void countCurePigs() {
		Integer response = null;
		response = service.countCurePigs();
		// TODO: JUnit - Add assertions to test outputs of operation: countCurePigs
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureTaskCourse entity
	* 
	 */
	@Test
	public void deleteCurePigCureTaskCourse() {
		// TODO: JUnit - Populate test inputs for operation: deleteCurePigCureTaskCourse 
		Integer curepig_id_2 = 0;
		Integer related_curetaskcourse_id = 0;
		CurePig response = null;
		response = service.deleteCurePigCureTaskCourse(curepig_id_2, related_curetaskcourse_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCurePigCureTaskCourse
	}

	/**
	 * Operation Unit Test
	* Load an existing CurePig entity
	* 
	 */
	@Test
	public void loadCurePigs() {
		Set<CurePig> response = null;
		response = service.loadCurePigs();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCurePigs
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
